package model.entities;
// Generated Dec 25, 2013 4:41:07 AM by Hibernate Tools 3.2.1.GA


import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.googlecode.jsonplugin.annotations.JSON;


/**
 * Post generated by hbm2java
 */
@Entity
@Table(name="post"
    ,catalog="bocauchithu"
)
public class Post  implements java.io.Serializable {


     private Integer id;
     private User user;
     private Category category;
     private String name;
     private String content;
     private Date createTime;
     private Set<Comment> comments = new HashSet<Comment>(0);

    public Post() {
    }

	
    public Post(User user, Category category) {
        this.user = user;
        this.category = category;
    }
    public Post(User user, Category category, String name, String content, Date createTime, Set<Comment> comments) {
       this.user = user;
       this.category = category;
       this.name = name;
       this.content = content;
       this.createTime = createTime;
       this.comments = comments;
    }
    public Post(User user, Category category, String name, String content, Date createTime) {
        this.user = user;
        this.category = category;
        this.name = name;
        this.content = content;
        this.createTime = createTime;
     }
     @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)
    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="user_id", nullable=false)
    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
@ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="category_id", nullable=false)
    public Category getCategory() {
        return this.category;
    }
    
    public void setCategory(Category category) {
        this.category = category;
    }
    
    @Column(name="name", length=200)
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(name="content", length=65535)
    public String getContent() {
        return this.content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="create_time", length=19)
    public Date getCreateTime() {
        return this.createTime;
    }
    
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JSON(serialize = false)
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="post")
    public Set<Comment> getComments() {
        return this.comments;
    }
    
    public void setComments(Set<Comment> comments) {
        this.comments = comments;
    }




}


